package cn.basic.social.api.dingtalk;

import cn.basic.social.api.BaseResponse;

import java.io.Serializable;

/**
 * @ClassName DingResponse
 * @Description 钉钉基础返回值
 * @Author zlf
 * @Date 2023/8/25 10:03
 */
public abstract class DingResponse extends BaseResponse implements Serializable {

    /**
     * 出错返回码
     */
    private String code;

    /**
     * 返回码提示语
     */
    private String message;

    /**
     * 请求唯一标识
     */
    private String requestid;

    /**
     * 出错返回码，为0表示成功，非0表示调用失败
     */
    private Integer errcode;

    public DingResponse() {
    }

    public DingResponse(String code, String message, String requestid, Integer errcode) {
        this.code = code;
        this.message = message;
        this.requestid = requestid;
        this.errcode = errcode;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getRequestid() {
        return requestid;
    }

    public void setRequestid(String requestid) {
        this.requestid = requestid;
    }

    public Integer getErrcode() {
        return errcode;
    }

    public void setErrcode(Integer errcode) {
        this.errcode = errcode;
    }

    /**
     * 判断请求是否成功，这里判断code码
     *
     * @return true成功；false失败
     * @author zlf
     * @date 10:07 2023/8/25
     */
    @Override
    public boolean isSuccess() {
        return (this.errcode != null && this.errcode == 0 && (this.code == null || this.code.length() <= 0))
                || ((this.errcode == null) && (this.code == null || this.code.length() == 0));
    }
}
